<?php

namespace app\common\model\billiard;

use app\common\model\mycurrency\DeviceLattice;
use app\common\model\mycurrency\LeaseStrategy;
use think\Exception;
use think\Model;
use traits\model\SoftDelete;

class StoreGoods extends Model
{

    //use SoftDelete;


    // 表名
    protected $name = 'billiard_store_goods';

    const STATUS_ZHENGCHENG = 1;//代理商状态 = 正常
    const STATUS_JINYONG = 2;//代理商状态 = 禁用




    public function strategy(){
        return $this->hasOne(LeaseStrategy::class, 'id', 'lease_strategy_id');
    }

    public function goods(){
        return $this->hasOne(Goods::class, 'id', 'goods_id');
    }

    //获取商品在某个柜子上的总数
    public function goodsAssemble(){
        return $this->hasMany(DeviceLattice::class, 'store_goods_id', 'id', [], 'LEFT');
    }

    //获取商品在某个柜子上的可用数量
    public function goodsAvailable(){
        return $this->hasMany(DeviceLattice::class, 'store_goods_id', 'id', [], 'LEFT');
    }
}
